package com.itboye.mengwu.data.repository;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.utils.BaseErrorListener;
import com.itboye.core.utils.BaseSuccessReqListener;
import com.itboye.core.utils.ByJsonRequest.Builder;
import com.itboye.mengwu.data.interfaces.INewMaMaZeng;
import com.itboye.mengwu.data.model.MaMaZengFaBuFenLeiBean;
import com.itboye.mengwu.data.model.MaMaZengShouCangFenYeModel;
import com.itboye.mengwu.data.model.NewMaMaZengBean;
import com.itboye.mengwu.data.model.NewMaMaZengXiangQing;
import com.itboye.mengwu.data.model.WodeZengSongShangPingBean;
import com.itboye.mengwu.ui.shop.GoodsDetailsRootBean;

import android.util.Log;

public class NewMaMaZengRepository extends BaseNetRepository implements INewMaMaZeng<NewMaMaZengBean> {

	String api = "100";
	// 18 赠无限
	// 18.1 发布
	public static final String Fabu = "BY_Product_addGift";
	// 18.2 收藏
	public static final String Shoucang = "BY_Product_favorites";
	// 18.3 列表 - 分页
	public static final String Liebiaofenye = "BY_Product_listGift";
	// 18.5 申请
	public static final String Shenqing = "BY_Product_applyGift";
	// 18.4 详情
	public static final String Xiangqing = "BY_Product_detailGift";
	// 18.6 申请 - 分页
	public static final String Shenqingfenye = "BY_Product_applyList";
	// 18.7 赠送 - 选择
	public static final String Zengsongxuanze = "BY_Product_chose";
	// 18.8 发货
	public static final String Fahuo = "BY_Product_express";
	// 18.9 评价
	public static final String PingJia = "BY_Product_commentGift";
	// 18.10 收藏 - 分页
	public static final String Shoucangfenye = "BY_Product_queryFavGift";
	// 18.11 类目 - 不分页
	public static final String Leimubufenye = "BY_Product_giftCate";

	public NewMaMaZengRepository() {
		super();
	}

	public NewMaMaZengRepository(ICompleteListener listener) {
		super(listener);
	}

	@Override
	public void add(NewMaMaZengBean model) {

	}

	@Override
	public void delete(NewMaMaZengBean model) {

	}

	@Override
	public void update(NewMaMaZengBean model) {

	}

	@Override
	public void getInfo(NewMaMaZengBean model) {

	}

	@Override
	public List<NewMaMaZengBean> queryYouHuiQuan(NewMaMaZengBean model) {
		return null;
	}

	@Override
	public void fabu(String uid, String title, String message, String cate_id, String template, String show_imgs,
			String zone_id, String main_img) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "101";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("title", title);
		params.put("message", message);
		params.put("cate_id", cate_id);
		params.put("template", template);
		params.put("show_imgs", show_imgs);
		params.put("zone_id", zone_id);
		params.put("main_img", main_img);

		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(Fabu, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void shoucang(String pid, String uid, String favorite_value, String fav_type) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);
		params.put("uid", uid);
		params.put("favorite_value", favorite_value);
		params.put("fav_type", fav_type);

		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(Shoucang, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void libiaofenye(String name, String cate_id, String page_no, String page_size, String order, String zone,
			String uid, String to_uid) {
		Type type = new TypeToken<WodeZengSongShangPingBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", name);
		params.put("cate_id", cate_id);
		params.put("page_no", page_no);
		params.put("page_size", page_size);
		params.put("order", order);
		params.put("zone_id", zone);
		params.put("uid", uid);
		params.put("to_uid", to_uid);

		// 目前最简化调用
		// START
		(new Builder<WodeZengSongShangPingBean>()).setTypeVerParamsAndReturnClass(Liebiaofenye, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<WodeZengSongShangPingBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void shenqing(String pid, String uid, String reason, String address_id) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);
		params.put("uid", uid);
		params.put("reason", reason);
		params.put("address_id", address_id);

		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(Shenqing, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void xiangqing(String pid, String uid, String page_size) {
		Type type = new TypeToken<NewMaMaZengXiangQing>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);
		params.put("uid", uid);
		params.put("page_size", page_size);

		// 目前最简化调用
		// START
		(new Builder<NewMaMaZengXiangQing>()).setTypeVerParamsAndReturnClass(Xiangqing, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<NewMaMaZengXiangQing>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void shenqingfenye(String pid, String page_no, String page_size) {
		Type type = new TypeToken<NewMaMaZengBean>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);
		params.put("page_no", page_no);
		params.put("page_size", page_size);

		// 目前最简化调用
		// START
		(new Builder<NewMaMaZengBean>()).setTypeVerParamsAndReturnClass(Shenqingfenye, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<NewMaMaZengBean>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void zengsongxuanze(String pid, String apply_id, String uid) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("pid", pid);
		params.put("apply_id", apply_id);
		params.put("uid", uid);

		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(Zengsongxuanze, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void fahuo(String uid, String pid, String express_no, String express_code) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("pid", pid);
		params.put("express_no", express_no);
		params.put("express_code", express_code);

		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(Fahuo, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void pingjia(String uid, String pid, String content, String score1, String score2, String score3,
			String attachments,String send) {
		Type type = new TypeToken<String>() {
		}.getType();
		String apiVer = "101";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("pid", pid);
		params.put("content", content);
		params.put("score1", score1);
		params.put("score2", score2);
		params.put("score3", score3);
		params.put("attachments", attachments);
		params.put("send", send);
		// 目前最简化调用
		// START
		(new Builder<String>()).setTypeVerParamsAndReturnClass(PingJia ,apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<String>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void shoucangfenye(String uid ,String page_no,String page_size ,String max_img) {
		Type type = new TypeToken<MaMaZengShouCangFenYeModel>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("page_no", page_no);
		params.put("page_size",page_size);
		params.put("max_img", max_img);

		// 目前最简化调用
		// START
		(new Builder<MaMaZengShouCangFenYeModel>()).setTypeVerParamsAndReturnClass(Shoucangfenye, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<MaMaZengShouCangFenYeModel>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

	@Override
	public void leimubufenye() {
		Type type = new TypeToken<ArrayList<MaMaZengFaBuFenLeiBean>>() {
		}.getType();
		String apiVer = api;
		Map<String, Object> params = new HashMap<String, Object>();
//		 params.put("pah", uid);
		
		// 目前最简化调用
		// START
		(new Builder<ArrayList<MaMaZengFaBuFenLeiBean>>()).setTypeVerParamsAndReturnClass(Leimubufenye, apiVer, params, type)
				.requestListener(new BaseSuccessReqListener<ArrayList<MaMaZengFaBuFenLeiBean>>(getListener()))
				.errorListener(new BaseErrorListener(getListener())).desEncodeThenBuildAndSend();
	}

}
